package com.atguigu.petstore.common.util;

/**
 * @author lfy
 * @Description
 * @create 2023-09-27 13:59
 */
public class NumberUtils {

    /**
     * 生成一个 N 位数字
     * @return
     */
    public static String genNnum(int n){

        long round = Math.round(Math.random() * Math.pow(10,n+2));
//        System.out.println(round);

        String result ="";
        String x = round + "";
        if(x.length() >= n){
            result = x.substring(0, n);
        }else {
            //不够6位
            for (int i = 0; i < n - x.length(); i++) {
                result+="0";
            }
            result+=x;
        }
        return result;
    }
}
